package commom;

public class RGB {
    int r;
    int g;
    int b;

    int rgbInt;

    public int getR() {
        return r;
    }

    public void setR(int r) {
        this.r = r;
    }

    public int getG() {
        return g;
    }

    public void setG(int g) {
        this.g = g;
    }

    public int getB() {
        return b;
    }

    public void setB(int b) {
        this.b = b;
    }

    public RGB(int r, int g, int b) {
        this.r = r;
        this.g = g;
        this.b = b;
        this.rgbInt = convertRgbToArgb(r, g, b);
    }

    public String toString() {
        return "rgb(" + r + ", " + g + ", " + b + ") " + rgbInt;
    }

    public static RGB convertArgbToRgb(int argb) {
        int r = (argb & 0xff0000) >> 16;
        int g = (argb & 0xff00) >> 8;
        int b = (argb & 0xff);
        return new RGB(r, g, b);
    }

    public static int convertRgbToArgb(int r, int g, int b) {
        return 0xff000000 | (r << 16) | (g << 8) | b;
    }
}